package com.chenfan.service.impl;

import com.chenfan.anno.Log;
import com.chenfan.mapper.SumMapper;
import com.chenfan.pojo.PageBean;
import com.chenfan.pojo.Sum;
import com.chenfan.service.SumService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SumServiceimpl implements SumService {
    @Autowired
    private SumMapper sumMapper;

    @Log
    @Override
    public void add(Integer id) {
        sumMapper.add(id);
    }

    @Override
    public void take(Integer id) {
        sumMapper.take(id);
    }

    /*@Override
    public List<Sum> list() {
        return sumMapper.total();
    }*/

    @Override
    public PageBean page(Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);
        List<Sum> sumList=sumMapper.list();
        Page<Sum> sums=(Page<Sum>) sumList;
         PageBean pageBean = new PageBean(sums.getTotal(), sums.getResult());
        return pageBean;
    }
}
